From 464379d28540ae1a2eb72602fb06b5e9f04f2003 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Tue, 13 Dec 2005 18:06:03 +0000 Subject: [PATCH] Resurrect vifname xm create vif option support. This was present in earlier versions of Xen, and allows one to name a vif when it is created. This is useful for integration with IP accounting packages, for example. Closes bug #439. Signed-off-by: Ewan Mellor --- tools/examples/vif-common.sh | 11 +++++++++++ tools/python/xen/xend/server/netif.py | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/examples/vif-common.sh b/tools/examples/vif-common.sh index 8c997f0d99..3cbaa591b1 100644 --- a/tools/examples/vif-common.sh +++ b/tools/examples/vif-common.sh @@ -53,6 +53,17 @@ XENBUS_PATH="${XENBUS_PATH:?}" vif="${vif:?}" +vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "") +if [ "$vifname" ] +then + if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null + then + do_or_die ip link set "$vif" name "$vifname" + fi + vif="$vifname" +fi + + function frob_iptable() { if [ "$command" == "online" ] diff --git a/tools/python/xen/xend/server/netif.py b/tools/python/xen/xend/server/netif.py index 9269d83ae0..1b073b3939 100644 --- a/tools/python/xen/xend/server/netif.py +++ b/tools/python/xen/xend/server/netif.py @@ -74,9 +74,10 @@ class NetifController(DevController): typ = sxp.child_value(config, 'type') if typ == 'ioemu': return (None,{},{}) - bridge = sxp.child_value(config, 'bridge') - mac = sxp.child_value(config, 'mac') - ipaddr = _get_config_ipaddr(config) + bridge = sxp.child_value(config, 'bridge') + mac = sxp.child_value(config, 'mac') + vifname = sxp.child_value(config, 'vifname') + ipaddr = _get_config_ipaddr(config) devid = self.allocateDeviceID() @@ -90,6 +91,8 @@ class NetifController(DevController): back['ip'] = ' '.join(ipaddr) if bridge: back['bridge'] = bridge + if vifname: + back['vifname'] = vifname front = { 'handle' : "%i" % devid, 'mac' : mac } @@ -102,9 +105,8 @@ class NetifController(DevController): result = DevController.configuration(self, devid) - (script, ip, bridge, mac) = self.readBackend(devid, - 'script', 'ip', 'bridge', - 'mac') + (script, ip, bridge, mac, typ, vifname) = self.readBackend( + devid, 'script', 'ip', 'bridge', 'mac', 'type', 'vifname') if script: result.append(['script', @@ -116,5 +118,9 @@ class NetifController(DevController): result.append(['bridge', bridge]) if mac: result.append(['mac', mac]) + if typ: + result.append(['type', typ]) + if vifname: + result.append(['vifname', vifname]) return result -- 2.30.2